package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.FishingNetRecovery;
import com.ruoyi.system.service.IFishingNetRecoveryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * FishingNetRecoveryController
 */
@RestController
@RequestMapping("/system/recovery")
public class FishingNetRecoveryController extends BaseController
{
    @Autowired
    private IFishingNetRecoveryService fishingNetRecoveryService;

    /**
     * 查询渔网回收列表
     */
    @PreAuthorize("@ss.hasPermi('system:recovery:list')")
    @GetMapping("/list")
    public TableDataInfo list(FishingNetRecovery fishingNetRecovery)
    {
        startPage();
        List<FishingNetRecovery> list = fishingNetRecoveryService.selectFishingNetRecoveryList(fishingNetRecovery);
        return getDataTable(list);
    }

    /**
     * 导出渔网回收列表
     */
    @PreAuthorize("@ss.hasPermi('system:recovery:export')")
    @Log(title = "渔网回收", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FishingNetRecovery fishingNetRecovery)
    {
        List<FishingNetRecovery> list = fishingNetRecoveryService.selectFishingNetRecoveryList(fishingNetRecovery);
        ExcelUtil<FishingNetRecovery> util = new ExcelUtil<FishingNetRecovery>(FishingNetRecovery.class);
        util.exportExcel(response, list, "渔网回收数据");
    }

    /**
     * 获取渔网回收详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:recovery:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fishingNetRecoveryService.selectFishingNetRecoveryById(id));
    }

    /**
     * 新增渔网回收
     */
    @PreAuthorize("@ss.hasPermi('system:recovery:add')")
    @Log(title = "渔网回收", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FishingNetRecovery fishingNetRecovery)
    {
        return toAjax(fishingNetRecoveryService.insertFishingNetRecovery(fishingNetRecovery));
    }

    /**
     * 修改渔网回收
     */
    @PreAuthorize("@ss.hasPermi('system:recovery:edit')")
    @Log(title = "渔网回收", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FishingNetRecovery fishingNetRecovery)
    {
        return toAjax(fishingNetRecoveryService.updateFishingNetRecovery(fishingNetRecovery));
    }

    /**
     * 删除渔网回收
     */
    @PreAuthorize("@ss.hasPermi('system:recovery:remove')")
    @Log(title = "渔网回收", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fishingNetRecoveryService.deleteFishingNetRecoveryByIds(ids));
    }
}
